<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of BSpaceGroup
 *
 * @author ID59C
 */
class BSpaceGroup extends BGroup {

    const Group_Category = "Space_category";
    const Group_SpaceType = "Space_type";
    const Group_SpaceType_NormalSpace = "Space_type_normal";
    const Group_SpaceType_PersonalSpace = "Space_type_personal";
    const Group_Category_Business = "Space_category_business";
    const Group_Category_Public = "Space_category_public";
    const Group_Category_NoneProfit = "Space_category_none_profit";
    const Group_Category_General = "Space_category_general";
    const AllSpaces = "all_Spaces";
    const Not_Exit_Space = "not_exit_Space";

    public $name = null;
    public $data = null;
    public $status = null;
    public $description = null;

    public static function getSpaceCategoryList($resultFormat = 'stringList') {
        //$categories = array();
        $categoryGroup = self::find(BSpaceGroup::Group_Category);
        $categories = $categoryGroup->getChildren();
        
        if($resultFormat == 'stringList'){
            $categoryList = array();
            if(is_array($categories)){
                foreach ($categories as $id => $category) {
                    $categoryName = $category->getName();
                    switch ($categoryName)
                    {
                        case BSpaceGroup::Group_Category_General:
                          $categoryName = Yii::t('site',BSpaceGroup::Group_Category_General);
                          break;
                        case BSpaceGroup::Group_Category_Business:
                          $categoryName = Yii::t('site',BSpaceGroup::Group_Category_Business);
                          break;
                        case BSpaceGroup::Group_Category_Public:
                          $categoryName = Yii::t('site',BSpaceGroup::Group_Category_Public);
                          break;
                        case BSpaceGroup::Group_Category_NoneProfit:
                          $categoryName = Yii::t('site',BSpaceGroup::Group_Category_NoneProfit);
                          break;
                        default:
                          $categoryName = Yii::t('site',BSpaceGroup::Group_Category_General);
                    }
                    $categoryList[$id] = $categoryName;
                }
            }
            return $categoryList;
        }
        
        return $categories;
        
    }
    
     public static function getSpaceTypeList($resultFormat = 'stringList') {
        //$categories = array();
        $categoryGroup = self::find(BSpaceGroup::Group_SpaceType);
        if($categoryGroup != null)
        {
        $categories = $categoryGroup->getChildren();
        
        if($resultFormat == 'stringList'){
            $categoryList = array();
            if(is_array($categories)){
                foreach ($categories as $id => $category) {
                    $categoryList[$id] = $category->getName();
                }
            }
            return $categoryList;
        }
        }
        else{
             $categoryList = array();
             $categoryList[BSpaceGroup::Group_SpaceType_NormalSpace] = BSpaceGroup::Group_SpaceType_NormalSpace;
             $categoryList[BSpaceGroup::Group_SpaceType_PersonalSpace] = BSpaceGroup::Group_SpaceType_PersonalSpace;
             return $categoryList;
        }
        
        return $categories;
        
    }

}

?>
